<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Realm - Users</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="author" content="Bluth Company">
    <link rel="shortcut icon" href="__STATIC__/admin/assets/ico/favicon.html">
    <link href="__STATIC__/admin/assets/css/bootstrap.css" rel="stylesheet">
    <link href="__STATIC__/admin/assets/css/theme.css" rel="stylesheet">
    <link href="__STATIC__/admin/assets/css/font-awesome.min.css" rel="stylesheet">
    <link href="__STATIC__/admin/assets/css/alertify.css" rel="stylesheet">
    <link rel="Favicon Icon" href="favicon.ico">
  </head>
  <body>
    {include file="public:header"/}
    
    <div class="container-fluid">
	  {include file="public:sidemenu"/}
      <!-- Side menu -->  
     
      <!-- Main window -->
      <div class="main_container" id="users_page">

        <div class="row-fluid">
          <ul class="breadcrumb">
            <li><a href="#">首页</a> <span class="divider">/</span></li>
            <li class="active">视频</li>
          </ul>
       
        </div> <!-- /row-fluid -->

        

        <div class="row-fluid">
          <div class="widget widget-padding span12">
            <div class="widget-header">
              <i class="icon-group"></i>
              <h5>视频</h5>
              <div class="widget-buttons">
                  <a href="#" data-title="Add User" data-toggle="modal" data-target="#example_modal"><i class="icon-plus"></i></a>
                  <a href="#" data-title="Collapse" data-collapsed="false" class="collapse"><i class="icon-chevron-up"></i></a>
              </div>
            </div>  
            <div class="widget-body">
              <table id="videos" class="table table-striped table-bordered dataTable">
                <thead>
                  	<tr>
											<th>视频名称</th>
											<th>海报</th>
											<th>视频类型</th>
											<th>简介</th>
											<th>上传日期</th>
										</tr>
                </thead>
                <tbody>
                 {volist name="videos" id="vo"}
			 								<tr>
			 								<td>{$vo.videoname}</td>
			 								<td><img src="__STATIC__/admin/posters/{$vo.pic}" width="200"></td>
			 								<td>{$vo.typename}</td>
			 								<td>{$vo.intro}</td>
			 								<td>{$vo.uploaddate}</td>
                    <td>
                      <div class="btn-group">
                        <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
                       		 操作
                          <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu pull-right">
                          <li><a href="#" data-toggle="modal" data-target="#example_modal2" onclick="jsedit({$vo.vid})"><i class="icon-edit"></i>修改</a></li>
                          <li><a href="{:url('video/delete',['id'=>$vo.vid])}"><i class="icon-trash"></i>删除</a></li>
                        </ul>
                      </div>
                    </td>
                  </tr>
                  
                  {/volist}
                  
                </tbody>
              </table>
            </div> <!-- /widget-body -->
          </div> <!-- /widget -->
        </div> <!-- /row-fluid -->

      </div>
      <!-- /Main window -->

    </div><!--/.fluid-container-->
    </div><!-- wrap ends-->

    <!-- Example Modal -->
    <div id="example_modal" class="modal hide fade" style="width: 430px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">添加视频信息</h3>
      </div>
      <div class="modal-body">
        <p>
        	 <form class="form-horizontal" method="post" action="{:url('video/add')}" enctype="multipart/form-data">
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label" >视频名称</label>
                    <div class="controls">
                      <input class="span7" style="width: 300px;" type="text" placeholder="videoname" name="videoname">
                    </div>
                  </div>
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label">视频类型</label>
                      <div class="controls">
                        <select tabindex="1" data-placeholder="Select here.." class="span7" style="width: 300px;" name="videotype">
                           {volist name="types" id="tp"}
  														<option value={$tp.tid}>{$tp.typename}</option>
							  					 {/volist}
                        </select>
                     </div>
                  </div>
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label">视频海报</label>
                    <div class="controls">
                      <input type="file" id="exampleInputFile" name="pic" required>
                    </div>
                  </div>
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label">视频简介</label>
                      <div class="controls">
                        <textarea class="span7" rows="5" style="height:100px; width: 300px;" name="videointro"></textarea>
                      </div>
                  </div>
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label">下载地址</label>
                    <div class="controls">
                     <input class="span7" style="width: 300px;" type="text" data-items="4" data-provide="typeahead" style="margin: 0 auto;" placeholder="address" name="address">
                    </div>
                  </div>                  
                  
                  <div>
               <button class="btn btn-primary" type="submit">添加</button>
               <button class="btn" type="reset">重置</button>
    				</div>
                </form>
        </p> 
      </div>
    </div>  

<div id="example_modal2" class="modal hide fade" style="width: 430px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">添加视频信息</h3>
      </div>
      <div class="modal-body">
        <p>
        	 <form class="form-horizontal" method="post" action="{:url('video/update')}" enctype="multipart/form-data">
                  <input type="hidden" name="vid" id="vida">
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label" >视频名称</label>
                    <div class="controls">
                      <input class="span7" style="width: 300px;" type="text" placeholder="videoname" name="videoname" id="videonamea">
                    </div>
                  </div>
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label">视频类型</label>
                      <div class="controls">
                        <select tabindex="1" data-placeholder="Select here.." class="span7" style="width: 300px;" name="videotype">
                           {volist name="types" id="tp"}
  														<option value={$tp.tid}>{$tp.typename}</option>
							  					 {/volist}
                        </select>
                     </div>
                  </div>
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label">视频海报</label>
                    <div class="controls">
                      <input type="file" id="exampleInputFile" name="pic"  required>
                    </div>
                  </div>
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label">视频简介</label>
                      <div class="controls">
                        <textarea class="span7" rows="5" style="height:100px; width: 300px;" 
                        	name="videointro" id="videointroa"></textarea>
                      </div>
                  </div>
                  <div class="control-group" style="margin-left:-100px ;">
                    <label class="control-label">下载地址</label>
                    <div class="controls">
                     <input class="span7" style="width: 300px;" type="text" data-items="4" 
                     	data-provide="typeahead" style="margin: 0 auto;" 
                      name="address" id="addressa">
                    </div>
                  </div>                  
                  
                  <div>
               <button class="btn btn-primary" type="submit">添加</button>
               <button class="btn" type="reset">重置</button>
    				</div>
                </form>
        </p>  
      </div>
    </div>  
    {include file="public:footer"/}
    <script>
        function jsedit(vid){
          //从数据库中根据tid获取记录
          $.getJSON("{:url('video/edit')}",{"vid":vid},function(json){ 

            //显示在模态框中
            $("#vida").val(json.vid);
            $("#videonamea").val(json.videoname);
            $("#videointroa").val(json.intro);
            $("#addressa").val(json.address);
          }

            );
        }

    </script>
  </body>
</html>
